<?php

namespace app\adminapi\controller\system;

use app\adminapi\service\SysDictTypeService;
use app\adminapi\validate\SysDictTypeValidate;
use app\common\controller\BaseAdminController;

class SysDictTypeController extends BaseAdminController
{
    public array $notNeedLogin = [];

    public function list()
    {
        $params = (new SysDictTypeValidate())->get()->goCheck('list');
        $result = (new SysDictTypeService())->list($params);
        return app('json')->successWithData($result);
    }

    /**
     * @title   新增字典类型
     * @businessType    INSERT
     */
    public function insert()
    {
        $params = (new SysDictTypeValidate())->post()->goCheck('insert');
        $result = (new SysDictTypeService())->addSysDictType($params);
        return app('json')->successWithData($result);
    }

    /**
     * @title   删除字典类型
     * @businessType    DELETE
     */
    public function delete()
    {
        $params = (new SysDictTypeValidate())->delete()->goCheck('delete');
        $result = (new SysDictTypeService())->deleteSysDictType($params['dictId']);
        return app('json')->successWithData($result);
    }

    /**
     * @title   修改字典类型
     * @businessType    UPDATE
     */
    public function update()
    {
        $params = (new SysDictTypeValidate())->put()->goCheck('update');
        $result = (new SysDictTypeService())->updateSysDictType($params);
        return app('json')->successWithData($result);
    }

    public function query()
    {
        $params = (new SysDictTypeValidate())->get()->goCheck('query');
        $result = (new SysDictTypeService())->getSysDictType($params['dictId']);
        return app('json')->successWithData($result);
    }
}